local Lua__yujincaijue = fk.CreateSkill {

  name = "Lua__yujincaijue",

  tags = {Skill.Charge}

}

local U = require "packages.utility.utility"

Fk:loadTranslationTable{

    ["Lua__yujincaijue"] = "余烬裁决",
    [":Lua__yujincaijue"] = "蓄力技（0/100），每个准备阶段/你使用【杀】/造成伤害/弃置一名角色牌后，你摸一张牌并获得5/10/15/20蓄力点（若为身份模式，获得的蓄力点均+5）。",
}

Lua__yujincaijue:addEffect(fk.EventPhaseStart, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(Lua__yujincaijue.name) and player:getMark("skill_charge") ~= 100 then 
            return target.phase == Player.Start
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local points = 5
        if room:isGameMode("role_mode") then
            points = points + 5
        end
        player:drawCards(1, Lua__yujincaijue.name)
        U.skillCharged(player, points) -- 增加蓄力点
    end,
})

Lua__yujincaijue:addEffect(fk.CardUsing, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(Lua__yujincaijue.name) and player:getMark("skill_charge") ~= 100 then 
            return target == player and data.card.trueName == "slash"
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local points = 10
        -- 身份模式额外加分
        if room:isGameMode("role_mode") then
            points = points + 5
        end
        player:drawCards(1, Lua__yujincaijue.name)
        U.skillCharged(player, points) -- 增加蓄力点
    end,
})
Lua__yujincaijue:addEffect(fk.Damage, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(Lua__yujincaijue.name) and player:getMark("skill_charge") ~= 100 then 
            return target == player
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local points = 15
        -- 身份模式额外加分
        if room:isGameMode("role_mode") then
            points = points + 5
        end
        player:drawCards(1, Lua__yujincaijue.name)
        U.skillCharged(player, points) -- 增加蓄力点
    end,
})
Lua__yujincaijue:addEffect(fk.AfterCardsMove, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(Lua__yujincaijue.name) and player:getMark("skill_charge") ~= 100 then 
            for _, move in ipairs(data) do
              if move.moveReason == fk.ReasonDiscard and move.proposer == player and move.from ~= player then
                   return true
                end
            end
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local points = 20

        -- 身份模式额外加分
        if room:isGameMode("role_mode") then
            points = points + 5
        end
        player:drawCards(1, Lua__yujincaijue.name)
        U.skillCharged(player, points) -- 增加蓄力点
    end,
})


Lua__yujincaijue:addLoseEffect(function(self, player)
    U.skillCharged(player, -0, -100)
end)

Lua__yujincaijue:addAcquireEffect(function(self, player)
    U.skillCharged(player, 0, 100)
end)


return Lua__yujincaijue